package cn.tedu.service;

import cn.tedu.mapper.RoleMapper;
import cn.tedu.pojo.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class RoleServiceImp implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    public List<Role> findAll() {
        return roleMapper.findAll();
    }

    public void save(Role role) {
        //使用uuid
        String roleId = UUID.randomUUID().toString();
        role.setRoleId(roleId);
        roleMapper.save(role);
    }

    public void delete(String[] roleIds) {
        roleMapper.delete(roleIds);
    }

    public Role findRoleById(String roleId) {
        return roleMapper.findRoleById(roleId);
    }

    public List<String> findRoleByUserId(String userId) {
        return roleMapper.findRoleByUserId(userId);
    }
    public void update(Role role) {
        roleMapper.update(role);
    }
}
